<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="main :: common_head">
    <style>
        .changeI {
            display: block;
            width: 100%;
            height: 100%;
        }

        ul li {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .navbar .nav > li > .dropdown-menu::before {
            display: none !important;
        }

        .navbar .nav > li > .dropdown-menu::after {
            display: none !important;
        }

        .dropdown-menu:hover, .dropdown-menu:hover {
            display: none !important;
        }

        .dropdown-menu:hover::before, .dropdown-menu:hover::after {
            display: none !important;
        }

        #myli > ul:hover::before {
            display: none;
        }

        .addPropertyBtn {
            display: inline-block;
            padding: 6px 12px;
            margin-bottom: 0;
            font-size: 14px;
            font-weight: 500;
            line-height: 20px;
            text-align: center;
            white-space: nowrap;
            vertical-align: middle;
            cursor: pointer;
            border: 1px solid #a7a9aa;
            -webkit-border-radius: 0px !important;
            border-radius: 5px !important;
        }
    </style>
</head>

<body>
<!--删除提示模态框1-->
<div class="modal fade" id="delcfmModel1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body">是否要删除？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="deleteEnergyTypeById()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除提示模态框结束-->

<!--删除提示模态框2-->
<div class="modal fade" id="delcfmModel2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel2">提示</h4>
            </div>
            <div class="modal-body">该能源属性正在使用中，无法删除!</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除提示模态框结束-->

<div id="app">
<div class="container-fluid-full">
    <div class="row-fluid">

        <noscript>
            <div class="alert alert-block span10">
                <h4 class="alert-heading">Warning!</h4>
                <p>You need to have <a href="" target="_blank">JavaScript</a> enabled to use this site.</p>
            </div>
        </noscript>

        <!-- start: Content -->
        <div id="content" class="span10" style="width: 100%;">
            <ul class="breadcrumb" th:if="${#request.getParameter('breadcrumb') == 'true'}">
                <li>
                    <i class="fas fa-circle-notch"></i>
                    <a id="home" href="#" onclick="parent.location.reload()">主页</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">属性展示</a></li>
            </ul>
            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header" data-original-title>
                        <h2><i class="halflings-icon white user"></i><span class="break"></span>属性展示</h2>
                        <div class="box-icon"></div>
                    </div>
                    <div class="box-content">
                        <div class="container" style="margin-left: 0px; margin-bottom: 10px;">
                            <a class="btn btn-primary " id="addPropertyBtn" th:href="@{/addProperty.html}">添加属性</a>
                        </div>
                        <table class="table table-striped table-bordered bootstrap-datatable datatable">
                            <thead>
                            <tr>
                                <th>属性ID</th>
                                <th>属性名</th>
                                <th>属性图片</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="energy:${energyTypeList}">
                                <td th:text="${energy.typeId}">1</td>
                                <td class="center" th:text="${energy.typeName}">主机组</td>
                                <td>
                                    <div>
                                        <img style="background-color: #578ebe;width: 40px;height: 40px;" th:src="${energy.iconPath}" alt="">
                                    </div>
                                </td>
                                <td class="center">
                                    <!-- 修改字体图标结束-->
                                    <a class="btn btn-info" title="修改" th:href="@{/energyType/get/}+${energy.typeId}">
                                        修改
                                    </a>
                                    <a class="btn btn-danger" href="#" title="删除" th:id="${energy.typeId}" onclick="deleteEnergyType()">删除</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div><!--/.fluid-container-->
        <!-- end: Content -->
    </div><!--/#content.span10-->
</div><!--/fluid-row-->
</div>

<div class="modal hide fade" id="myModal">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Settings</h3>
    </div>
    <div class="modal-body">
        <p>Here settings can be configured...</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
    </div>
</div>
<div class="common-modal modal fade" id="common-Modal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-content">
        <ul class="list-inline item-details">
            <li><a href="http://sc.chinaz.com">Admin templates</a></li>
            <li><a href="http://sc.chinaz.com">Bootstrap themes</a></li>
        </ul>
    </div>
</div>
<div class="clearfix"></div>

<div th:replace="main::common_js"></div>

<script>
    breadcrumb()
    window.onload = function() {
        parent.modifyTitle('能源属性')
    }
</script>

<script th:src="@{/js/detect-element-resize.js}"></script>
<script th:src="@{/js/iframe-resize.js}"></script>

<script>
    //点击删除按钮弹出模态框
    var deleteEnergyTypeId = "";

    function deleteEnergyType() {
        $("#delcfmModel1").modal("show");
        deleteEnergyTypeId = $(event.target).attr("id"); //获取当前点击按钮的id
        console.log(deleteEnergyTypeId);
    }

    //点击模态框确认按钮时删除能源属性
    function deleteEnergyTypeById() {
        $.ajax({
            type: "GET",
            url: "/multipower/energyType/deleteEnergyType/" + deleteEnergyTypeId,
            success: function (data) {
                if (data.message == "success") { //删除成功
                    $("#delcfmModel1").modal("hide");
                    location.reload();
                } else if (data.message == 'fail') {
                    $("#delcfmModel1").modal("hide");
                    $("#delcfmModel2").modal("show");
                }
            }
        })
    }
</script>
</body>
</html>
